<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
   <button onclick="changeItem()">zzy</button>
    <script>
        const signItem = localStorage.setItem
        localStorage.setItem = function(key, val) {
            let setEvent = new Event('setItem')
            setEvent.key = key
            setEvent.val = val
            window.dispatchEvent(setEvent)
            signItem.apply(this, arguments)
        }
        window.addEventListener('setItem', (e) => {
            console.log('我发生了变化啦');
            console.log(e);
        })
        function changeItem() {
            localStorage.setItem('zzy', '999')
        }
    </script>
</body>
</html>